﻿<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="Shortcut Icon" href="../images/aecc.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../StaticFiles/element-ui/element-ui.css">
  <link rel="stylesheet" href="../StaticFiles/nprogress/nprogress.min.css">
  <link rel="stylesheet" href="../styles/vue-page-common.css">
  <link rel="stylesheet" href="../styles/table-transparent.css">
  <script src="../Scripts/vue.min.js"></script>
  <script src="../StaticFiles/element-ui/element-ui.js"></script>
  <script src="../Scripts/axios.min.js"></script>
  <script src="../StaticFiles/nprogress/nprogress.min.js"></script>
  <script src="../Scripts/crypto-js.js"></script>
  <script src="../Scripts/secret.js"></script>
  <script src="../Scripts/dayjs.min.js"></script>
  <script src="../Scripts/axios.config.js"></script>
  <script src="../Scripts/datav.min.vue.js"></script>
  <script src="../Scripts/lodash.min.js"></script>
  <title>改复装机计划进度看板</title>
  <style>
    html {
      background-image: url(../images/bg.jpg);
      color: #fff;
    }

    .header-title {
      font-size: 24px !important;
    }

    .el-form-item__label {
      color: #fff;
    }

    .el-form-item {
      margin-bottom: 0px;
    }

    .el-table__header .el-table__cell {
      color: yellow !important;
    }

    .green {
      color: #00ff00;
      font-weight: bold;
    }

    .red {
      color: #FF0000;
      font-weight: bold;
    }
  </style>
</head>

<body>
  <div id="app" v-cloak>
    <div style="padding:0 5px;">
      <el-row>
        <el-col :span="6"><img src="../images/aeec_logo.png" height="60" alt="黎阳LOGO" /></el-col>
        <el-col :span="12" class="header-title">{{queryInfo.factoryname}}改复装机计划进度看板</el-col>
        <el-col :span="6" class="currentTime">{{currentTime}}</el-col>
      </el-row>

      <!-- 查询条件区 -->
      <el-form :inline="true" :model="queryInfo" ref="queryInfoRef" :label-position="'left'">
        <el-form-item prop='engineno' label="发动机号:">
          <el-autocomplete v-model="queryInfo.engineno" placeholder="请输入发动机号" :trigger-on-focus="false"
            :fetch-suggestions="getEngineNoAsync" :value-key="'engineno'" :debounce="500" style="width:300px;">
          </el-autocomplete>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="small" @click="search">查询</el-button>
        </el-form-item>
      </el-form>

      <!-- 页面主表格 -->
      <dv-border-box-11 :title="engineno" ref="datagrid" :title-width="500">
        <div id="datagrid" style="padding: 30px;padding-top:70px;padding-bottom:20px;">
          <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
            element-loading-background="rgba(0,0,0,0.8)" :data="dataList" stripe border>
            <el-table-column type="index" width="50px"></el-table-column>
            <el-table-column label="工序" prop="workflowstepname" width="200" show-overflow-tooltip></el-table-column>
            <el-table-column label="工步" prop="stepinfodesc" width="200" show-overflow-tooltip></el-table-column>
            <el-table-column label="开始时间" prop="plannedstartdate" width="120" show-overflow-tooltip>
              <template slot-scope="scope" v-if="scope.row.plannedstartdate">
                {{scope.row.plannedstartdate.split('T')[0]}}
              </template>
            </el-table-column>
            <el-table-column label="结束时间" prop="plannedfinishdate" width="120" show-overflow-tooltip>
              <template slot-scope="scope" v-if="scope.row.plannedfinishdate">
                {{scope.row.plannedfinishdate.split('T')[0]}}
              </template>
            </el-table-column>
            <el-table-column label="周期" prop="cycle" width="80" show-overflow-tooltip></el-table-column>
            <el-table-column label="完成时间" prop="finishdate" width="140" show-overflow-tooltip>
              <template slot-scope="scope" v-if="scope.row.finishdate">
                <span v-if="scope.row.color === 'red'" class="red">
                  {{scope.row.finishdate}}
                </span>
                <span v-else-if="scope.row.color === 'green'" class="green">
                  {{scope.row.finishdate}}
                </span>
                <span v-else>
                  {{scope.row.finishdate}}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="差异分析" prop="exceednotes" show-overflow-tooltip></el-table-column>
          </el-table>
          <el-pagination @current-change="handleCurrentChange" :current-page="queryInfo.currentPage" :page-sizes="[1]"
            :page-size="queryInfo.pageSize" layout="prev,pager,next,jumper,sizes,total" :total="total">
          </el-pagination>
          <el-backtop></el-backtop>
        </div>
      </dv-border-box-11>
    </div>
  </div>
  <script type="module">
    import { getParams, fetchSuggestion } from '../Scripts/hooks/useCommonMethod.js'
    import { getFactoryInfo } from '../Scripts/hooks/fetchAPI.js';
    const app = new Vue({
      el: '#app',
      data: {
        currentTime: '',
        total: 0,
        loading: false,
        loadingText: '数据加载中...',
        dataList: [],
        queryInfo: { factoryname: '', engineno: '', currentPage: 1, pageSize: 1 },
        engineno: ''
      },
      methods: {
        // 查询发动机号
        getEngineNoAsync(value, callback) {
          fetchSuggestion({ actionName: 'getEngineNoAsync', name: 'engineno', value, callback });
        },
        search() {
          this.queryInfo.currentPage = 1;
          this.getData();
        },
        async getData() {
          this.loading = true;
          this.loadingText = '数据查询中...';
          const { data: { data, meta, total } } = await axios({
            method: 'post',
            url: '../handler/board/ZSXinJiStepPlanDashBoard.ashx?action=getData',
            data: { type: 'getData', ...this.queryInfo }
          })
          this.loading = false;
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.total = total;
          this.dataList = [];
          if (total > 0) {
            const { engineno } = data[0];
            this.getDetail(engineno);
            this.engineno = `发动机号：${engineno}`;
          } else {
            setTimeout(() => { this.$refs.datagrid.initWH(); }, 0);
          }
        },
        async getDetail(engineno) {
          this.loading = true;
          this.loadingText = '数据查询中...';
          const { data: { data, meta, total } } = await axios({
            method: 'post',
            url: '../handler/board/ZSXinJiStepPlanDashBoard.ashx?action=getDetail',
            data: { type: 'getDetail', engineno }
          })
          this.loading = false;
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.dataList = data;
          setTimeout(() => { this.$refs.datagrid.initWH(); }, 0);
        },
        handleCurrentChange(newPage) {
          this.queryInfo.currentPage = newPage;
          this.getData();
        }
      },
      async mounted() {
        let incrementNumber = () => {
          setTimeout(incrementNumber, 500);
          this.currentTime = dayjs().format('YYYY年MM月DD日  HH:mm:ss')
        }
        setTimeout(incrementNumber, 500);
        const factoryInfo = await getFactoryInfo({ factoryid: Decrypt(getParams('factoryid')), isMapping: '是' });//查询当前分厂信息
        const { factoryid, factoryname } = factoryInfo[0];
        this.queryInfo.factoryname = factoryname;
        document.title = factoryname + '改复装机计划进度看板';
        this.getData();
      }
    })
  </script>
</body>

</html>